<?php
// +----------------------------------------------------------------------
// | quanli team
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2020 http://www.fistforward.com/ All rights reserved.
// +----------------------------------------------------------------------
// | create by allen.qiang
// +----------------------------------------------------------------------

quanli_require('module/base/content/contentCenter.class.php');

/**
 * 活动页管理操作功能
 */

class pa_contentCenter {
	
	public function execute () {
		
		if (isset($_REQUEST['operFlg'])) {
			
			//获取参数
			$operFlg = $_REQUEST['operFlg'];

			switch ($operFlg) {
				case 1: //页面初始化
					$this->init();
					break;
					
				case 2: //添加内容
					$this->addContent();
					break;
					
				case 3: //编辑内容
					$this->editContent();
					break;

			}
		}
	}
	
	/**
	 * 页面初始化
	 *
	 */
	private function init(){
		global $G_PGLOB;
		
		//权限
		$edit_permission = $G_PGLOB->has_permission(1555);

        //add by allen.qiang 2015-01-13 FUN-BK-0045-PC_WAP首页底下广告位按城市维护 ---start
        $G_PGLOB->smarty->assign_by_ref('city_array', $G_PGLOB->getCache('city'));
        //add by allen.qiang 2015-01-13 FUN-BK-0045-PC_WAP首页底下广告位按城市维护 ---end

		$G_PGLOB->smarty->assign('edit_permission', $edit_permission);
		
		$G_PGLOB->smarty->display("content/contentList.tpl");
	}
	
	/**
	 * 添加内容
	 *
	 */
	private function addContent(){
		
		global $G_PGLOB;
		//获取默认排序序号
        $sortOrder = getSortNum('content_center', 'contentSort');
        $G_PGLOB->smarty->assign_by_ref('city_array', $G_PGLOB->getCache('city'));
		$G_PGLOB->smarty->assign('sortOrder',$sortOrder);
		$G_PGLOB->smarty->display('content/addContent.tpl');
	}
	
	/**
	 * 编辑活动页管理
	 *
	 */
	private function editContent(){
		
		global $G_PGLOB;
		
		$contentID = isset($_REQUEST['contentID']) ? trim($_REQUEST['contentID']) : null;
		
		if (empty($contentID)) {
			$G_PGLOB->smarty->display('comm/error.tpl');
			die();
		}
		
		$content_center = new entity('content_center');
		$content_center->contentID = $contentID;
		if (!$G_PGLOB->DBCA->fetch($content_center)) {
			$G_PGLOB->smarty->display('comm/error.tpl');
			die();
		}

        $content_center->content_pic_show = G_IMAGE_URL .  $content_center->content_pic;
        $G_PGLOB->smarty->assign_by_ref('city_array', $G_PGLOB->getCache('city'));
		$G_PGLOB->smarty->assign('sortOrder', $content_center->contentSort);
		$G_PGLOB->smarty->assign('content_center', $content_center);
		$G_PGLOB->smarty->display('content/addContent.tpl');
	}
}